//
//  CategoryGoodModel.swift
//  Pods
//
//  Created by eme on 2017/4/10.
//
//

import UIKit
import SwiftyJSON
import ModelProtocol

class CategoryGoodModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kCategoryGoodBrnameKey: String = "brname"
    internal let kCategoryGoodImg1Key: String = "img1"
    internal let kCategoryGoodPdnameKey: String = "pdname"
    internal let kCategoryGoodMinshpriceKey: String = "minshprice"
    internal let kCategoryGoodPdidKey: String = "pdid"
    internal let kCategoryStockKey: String = "stock"
    
    
    
    // MARK: 属性
    var brname: String
    var img1: String
    var pdname: String
    var minshprice: Double
    var pdid: String
    var stock:Int
    var bdprice:Double
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        brname = json[kCategoryGoodBrnameKey].stringValue
        img1 = json[kCategoryGoodImg1Key].stringValue
        pdname = json[kCategoryGoodPdnameKey].stringValue
        minshprice = json[kCategoryGoodMinshpriceKey].doubleValue
        pdid = json[kCategoryGoodPdidKey].stringValue
        stock = json[kCategoryStockKey].intValue
        bdprice = json["bdprice"].doubleValue
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        
        dictionary.updateValue(brname as AnyObject, forKey: kCategoryGoodBrnameKey)
    
        dictionary.updateValue(img1 as AnyObject, forKey: kCategoryGoodImg1Key)

        dictionary.updateValue(pdname as AnyObject, forKey: kCategoryGoodPdnameKey)
   
        dictionary.updateValue(minshprice as AnyObject, forKey: kCategoryGoodMinshpriceKey)
    
        dictionary.updateValue(pdid as AnyObject, forKey: kCategoryGoodPdidKey)
    
        dictionary.updateValue(stock as AnyObject, forKey: kCategoryStockKey)
        
        dictionary.updateValue(bdprice as AnyObject, forKey: "bdprice")
        
        return dictionary
    }
    
    
}
